import { createRouter, createWebHashHistory } from 'vue-router';
import AdminIndex from '@/pages/admin/index.vue';
import About from '@/pages/about.vue';
import NotFound from '@/pages/404.vue';
import AdminLogin from '@/pages/admin/login.vue';
import Admin from '@/layouts/admin.vue'
import EmployeeList from "@/pages/admin/employee-list.vue";
import CategoryList from "@/pages/admin/category-list.vue";
import GoodsList from "@/pages/admin/goods-list.vue";
import SetMealList from "@/pages/admin/set-meal-list.vue";
import OrdersList from "@/pages/admin/orders-list.vue";

const routes = [
    {
        // 指定访问路径
        path: '/admin',
        component: Admin,
        // 使用到 admin.vue 布局的，都需要放置在其子路由下面
        children: [{
            path: '/admin',
            component: AdminIndex,
            meta: {
                title: '仪表盘'
            }
        }, {
            path: '/admin/employee/list',
            component: EmployeeList,
            meta: {
                title: '员工管理'
            }
        }, {
            path: '/admin/category/list',
            component: CategoryList,
            meta: {
                title: '分类管理'
            }
        }, {
            path: '/admin/goods/list',
            component: GoodsList,
            meta: {
                title: '商品管理'
            }
        }, {
            path: '/admin/set_meal/setting',
            component: SetMealList,
            meta: {
                title: '套餐管理'
            }
        },{
            path: '/admin/order/setting',
            component: OrdersList,
            meta: {
                title: '订单明细'
            }
        }]

    },
    {
        path: '/about',
        component: About
    },
    // 将匹配所有内容并将其放在 `$route.params.pathMatch` 下
    {
        path: '/:pathMatch(.*)*',
        name: 'NotFound',
        component: NotFound
    },
    {
        path: '/login',
        component: AdminLogin,
        meta: {
            title: '登录页'
        }
    },

]

const router = createRouter({
    // 4. 内部提供了 history 模式的实现。为了简单起见，我们在这里使用 hash 模式。
    history: createWebHashHistory(),
    routes, // `routes: routes` 的缩写
})

// ES6 模块导出语句，它用于将 router 对象导出，以便其他文件可以导入和使用这个对象
export default router
